/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.lvyh.lightframe.job.enums;

public enum AlarmType {

    TASK(1, "task", "任务类型"),
    SYS(2, "sys", "系统自定义"),
    URGENT(3, "urgent", "紧急类型(间隔时间相对较短)"),
    ZK_TASK_NODE_MISS_DEL(4, "zk_task_node_miss_del", "任务异常后ZK任务临时节点未成功删除"),
    ZK_TASK_NODE_DELETE_QUEUE_FULL(5, "zk_task_node_delete_queue_full", "任务节点删除队列已满"),
    TASK_EXECUTE_EXCEPTION(6, "task_execute_exception", "任务执行异常"),
    UNKNOWN(99, "unknown", "其他");

    private int key;

    private String value;

    private String desc;

    AlarmType(int key, String value, String desc) {
        this.key = key;
        this.value = value;
        this.desc = desc;
    }

    public int getKey() {
        return key;
    }

    public void setKey(int key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static AlarmType convert(Integer key) {
        if (key != null) {
            AlarmType[] values = values();
            for (AlarmType result : values) {
                if (result.getKey() == key) {
                    return result;
                }
            }
        }

        return UNKNOWN;
    }

}
